<template>
  <div class="gl_heightFull gl_contentBox">
    <div style="margin-bottom:15px">
      <el-button v-loading="btnDownLoading" type="warning" size="mini" @click="exportpeople()">导出学员名单</el-button>
    </div>
    <div class="demo-input-suffix gl_searchBox">
      <el-row :gutter="20">
        <el-col :md="4" :lg="4">
          <p>学员姓名</p>
          <el-input v-model="Api_GET_ClubFeeStudentQO.Filter" placeholder="请输入学员姓名" size="mini" clearable @change="gettablelist()" />
        </el-col>
        <el-col :md="4" :lg="4">
          <p>证件号码</p>
          <el-input v-model="Api_GET_ClubFeeStudentQO.IdCardNumber" placeholder="请输入证件号码" size="mini" clearable @change="gettablelist()" />
        </el-col>
        <el-col :md="4" :lg="4">
          <p>缴费结果</p>
          <el-select v-model="Isstate" size="mini" @change="gettablelist()">
            <el-option label="全部" value="" />
            <el-option v-for="(item,index) in dict.feeStudentStatus" :key="index" :label="item.value" :value="item.code" />
          </el-select>
        </el-col>
        <el-col :md="4" :lg="4">
          <el-button type="primary" style="margin-top:25px" size="mini" @click="gettablelist()">筛选</el-button>
          <el-button type="warning" size="mini" @click="reset()">{{ $t('button.Reset') }}</el-button>
        </el-col>
      </el-row>
    </div>
    <div style="margin-top:15px">
      <el-table v-loading="tableLoading" class="gl_table_noBorder" size="mini" :data="tableData">
        <el-table-column label="序号" type="index" align="center" width="55" />
        <el-table-column label="姓名" width="54">
          <template slot-scope="{row}">
            <!-- <img class="roodsPhoto" :src="getStaticFileUrl(row.avatarUrl)" alt=""> -->
            <PersonalImage :imgurl="row.avatarUrl" imgheight="60px" />
          </template>
        </el-table-column>
        <el-table-column prop="registerStudent.name" />
        <el-table-column label="证件号码" prop="registerStudent.idCardNumber" />
        <el-table-column label="缴纳类型" align="center">
          <template slot-scope="{row}">
            <span v-if="row.memberFeeTypeCode">{{ row.memberFeeTypeCode === 'New'?'新增':'续费' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会员号" align="center" prop="memberNumber" />
        <el-table-column label="缴纳年限" align="center" prop="feeYear" />
        <el-table-column label="机构" align="center">
          <template slot-scope="{ row }">
            <el-popover placement="bottom" width="180" trigger="hover" :content="row.organizationUnitName">
              <div slot="reference" class="nav_left_top">{{ row.organizationUnitName }}</div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="缴费金额" align="center">
          <template slot-scope="{ row }">
            <span>
              {{ parseFloat( row.amount * 100) / 10000 }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="到期日期" align="center">
          <template slot-scope="{row}">
            <span v-if="row.exipiry">
              {{ row.exipiry | FormatDate('yyyy-MM-dd') }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="审核结果" align="center" prop="name">
          <template slot-scope="{row}">
            <span v-for="(item, index) in dict.feeStudentStatus" :key="index">{{ item.code == row.statusCode ? item.value : '' }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-row class="gl_pt_15" style="text-align: right;">
      <el-pagination
        :current-page="Api_GET_ClubFeeStudentQO.Page"
        :page-size="Api_GET_ClubFeeStudentQO.MaxResultCount"
        :total="totalPage"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 30, 40]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>

<script>
import PersonalImage from '@/components/PersonalImage/index';
import { api_GET_DownLoadFileAddHeader } from '@/extend/api/file';
import { mapState, mapActions } from 'vuex';
import { api_GET_ClubFeeStudent, api_GET_ClubFeeStudentFeeRequestOrderFeeRequestId } from '@/extend/api/hallswaggerApi/app.js';
import { Api_GET_ClubFeeStudentQO } from '@/lib/form/hall/swaggerForm';
export default {
  components: {

    PersonalImage
  },
  data() {
    return {
      btnDownLoading: false,
      GetStudentInput: {},
      offlineDialogVisible: false,
      modalPayLoding: false,
      dialogVisibleForPay: false,
      tableData: [],
      tableLoading: false,
      IsEnabled: '',
      Isstate: '',
      totalPage: 0,
      freeDate: [],

      Api_GET_ClubFeeStudentQO: new Api_GET_ClubFeeStudentQO() // 缴费学员数据
    };
  },
  computed: {
    ...mapState({
      dict: state => state.dict.dict,
      user: state => state.user.currentOU
    })
  },
  created() {
    this.getDict();
    this.gettablelist();
  },
  methods: {
    ...mapActions({ getDict: 'dict/getDict', getDictByType: 'dict/getDictByType' }),
    // 获取考试审核列表
    gettablelist(page) {
      this.Api_GET_ClubFeeStudentQO.StatusCode = this.Isstate;
      this.Api_GET_ClubFeeStudentQO.IncludeRegisterStudent = true;
      this.Api_GET_ClubFeeStudentQO.FeeRequestId = this.$route.query.id; // type: boolean
      this.tableLoading = true;
      this.Api_GET_ClubFeeStudentQO.Page = page || 1;
      this.Api_GET_ClubFeeStudentQO.SkipCount = (this.Api_GET_ClubFeeStudentQO.Page - 1) * this.Api_GET_ClubFeeStudentQO.MaxResultCount;
      api_GET_ClubFeeStudent(this.Api_GET_ClubFeeStudentQO).then(res => {
        console.log(res);
        this.totalPage = res.totalCount;
        this.tableData = res.items;
        this.tableLoading = false;
      }, error => {
        this.tableLoading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
      api_GET_ClubFeeStudentFeeRequestOrderFeeRequestId(this.$route.query.id).then(res => {
        console.log(res === '');
        if (res === '') {
          this.disbtn = false;
        } else {
          this.disbtn = true;
        }
      });
    },
    // 切换考试日期
    changeAttendance (val) {
      // const _start = val ? val[0] : null;
      // const _end = val ? val[1] : null;
      // const _qucikDateCode = this.matchQuickDate(_start, _end);
      // this.currentQuickDate = _qucikDateCode;
      this.gettablelist();
    },
    // 分页按钮
    sizeChange(MaxResultCount) {
      this.Api_GET_ClubFeeStudentQO.MaxResultCount = MaxResultCount;
      this.gettablelist();
    },
    pageIndexChange(currentPage) {
      this.gettablelist(currentPage);
    },
    // 重置按钮
    reset () {
      this.Isstate = '';
      this.Api_GET_ClubFeeStudentQO = new Api_GET_ClubFeeStudentQO();
      this.gettablelist();
    },
    // 获取静态文件
    getStaticFileUrl(relativeUrl) {
      if (!relativeUrl) return '';
      return WEB_CONFIG.VUE_APP_STATIC_FILE_RUL + relativeUrl;
    },
    exportpeople() {
      this.GetStudentInput.StatusCode = this.Isstate;
      this.GetStudentInput.IncludeRegisterStudent = true;
      this.GetStudentInput.FeeRequestId = this.$route.query.id; // type: boolean
      this.GetStudentInput.Filter = this.Api_GET_ClubFeeStudentQO.Filter;
      this.GetStudentInput = JSON.stringify(this.GetStudentInput);
      var that = this;
      const tempUrl = `/api/excel`;
      const fileName = '学员名单' + '.xlsx';
      this.btnDownLoading = true;
      api_GET_DownLoadFileAddHeader(tempUrl, fileName, { reportName: 'FeeStudent', GetFeeStudentsInput: this.GetStudentInput }, WEB_CONFIG.VUE_APP_SWAGGER_HALL_BASE).then(res => {
        that.btnDownLoading = false;
        this.GetStudentInput = {};
      }).catch(error => {
        this.GetStudentInput = {};
        that.btnDownLoading = false;
        errorText(error).then(function(text) {
          that.$message({ type: 'error', message: text });
        });
      });
    }
  }

};
</script>

<style lang="scss" scoped>
.pay_type.van-popup {
  background-color: transparent;
  z-index: 3015 !important; /* 覆盖组件原有层级，避免与summary弹层冲突 */
}
.pay_type_list {
  display: flex;
  justify-content: space-around;
}
.pay_type_item {
  width: 260px;
  height: 84px;
  padding: 0 50px;
  margin-bottom: 12px;
  text-align: right;
  color: #fff;
  font-size: 24px;
  line-height: 84px;
  cursor: pointer;
}
.pay_type_item:last-child {
  margin-bottom: 0;
}
.pay_type_online {
  background-image: url('../../../../assets/images/pay/online.png');
  background-repeat: no-repeat;
}
.pay_type_offline {
  background-image: url('../../../../assets/images/pay/offline.png');
  background-repeat: no-repeat;
}
  .roodsPhoto{
    width: 60px;
    height: 60px;
    vertical-align: middle;
  }
       .nav_left_top{
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
   }
</style>
